package com.tang.config;

import com.tang.system.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
@Slf4j
public class MvcExceptionHandler {
    @ExceptionHandler({Exception.class, RuntimeException.class})
    public Result handle(Exception e) {
        log.error(e.getMessage(), e);
        e.printStackTrace();
        return Result.error(e.getMessage());
    }
}
